package com.zhongan.gateway.web.common;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class PageDTO<T> implements Serializable {

    private static final long serialVersionUID = -3833322703735268137L;
    private int               limit;
    private int               start;
    private int               pageIndex;
    private long              results;
    private Object            param;
    private List<T>           rows;
    private boolean           needPage;
    private boolean           hasError;
    private String            error;

    public PageDTO() {
        limit = 20;
        start = 0;
        pageIndex = 0;
        results = 0L;
        rows = new ArrayList<T>();
        needPage = true;
        hasError = false;
    }

    public PageDTO(Object param) {
        limit = 20;
        start = 0;
        pageIndex = 0;
        results = 0L;
        rows = new ArrayList<T>();
        needPage = true;
        hasError = false;
        this.param = param;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    public boolean getNeedPage() {
        return needPage;
    }

    public void setNeedPage(boolean needPage) {
        this.needPage = needPage;
    }

    public Object getParam() {
        return param;
    }

    public void setParam(Object param) {
        this.param = param;
    }

    public long getResults() {
        return results;
    }

    public void setResults(long results) {
        this.results = results;
    }

    public boolean isHasError() {
        return hasError;
    }

    public void setHasError(boolean hasError) {
        this.hasError = hasError;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("PageDTO [limit=");
        builder.append(limit);
        builder.append(", start=");
        builder.append(start);
        builder.append(", pageIndex=");
        builder.append(pageIndex);
        builder.append(", results=");
        builder.append(results);
        builder.append(", param=");
        builder.append(param);
        builder.append(", rows=");
        builder.append(rows);
        builder.append(", needPage=");
        builder.append(needPage);
        builder.append(", hasError=");
        builder.append(hasError);
        builder.append(", error=");
        builder.append(error);
        builder.append("]");
        return builder.toString();
    }

}
